package com.evil.application.api;

import com.evil.application.config.FeignErrorDecoder;
import com.evil.application.pojo.dto.form.control.ControlBaseInfoDTO;
import com.evil.common.account.dto.user.UserBaseRespDTO;
import com.evil.common.account.dto.user.UserEnterpriseDTO;
import com.evil.common.application.dto.order.node.OrderNodeReqDTO;
import com.evil.common.application.dto.process.DynamicHandlerControlListReqDTO;
import com.evil.common.application.dto.process.node.*;
import com.evil.common.core.constant.ServiceNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 应用流程节点接口
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@FeignClient(name = ServiceNameConstant.APPLICATION_SERVICE, configuration = {FeignErrorDecoder.class})
public interface RemoteApplicationProcessNodeService {

    /**
     * 添加应用流程节点
     *
     * @param addNodeReqDTO addNodeReqDTO
     * @return NodeDTO
     */
    @PostMapping("/remote/application/process/node/add")
    NodeRespInfoDTO addApplicationProcessNode(@Validated @RequestBody AddNodeReqDTO addNodeReqDTO);

    /**
     * 删除应用流程节点
     *
     * @param nodeId nodeId
     */
    @PostMapping("/remote/application/process/node/delete")
    void deleteApplicationProcessNode(@RequestParam("nodeId") Long nodeId);

    /**
     * 编辑应用流程节点
     *
     * @param modifyNodeReqDTO modifyNodeReqDTO
     */
    @PostMapping("/remote/application/process/node/modify")
    void modifyApplicationProcessNode(@Validated @RequestBody ModifyNodeInfoReqDTO modifyNodeReqDTO);

    /**
     * 获取流程节点 可配置回退节点列表
     *
     * @param nodeId nodeId
     * @return List
     */
    @PostMapping("/remote/application/process/node/can-setting-fallbacks")
    List<NodeBaseDTO> canSettingFallbacks(@RequestParam("nodeId") Long nodeId);

    /**
     * 获取流程节点 可回退节点列表
     *
     * @param orderNodeReqDTO orderNodeReqDTO
     * @return List
     */
    @PostMapping("/remote/application/process/node/can-fallbacks")
    List<NodeBaseDTO> canFallbacks(@Validated @RequestBody OrderNodeReqDTO orderNodeReqDTO);

    /**
     * 获取流程节点 可转交人员列表
     *
     * @param nodeId nodeId
     * @return List
     */
    @PostMapping("/remote/application/process/node/can-reassignment")
    List<UserBaseRespDTO> canReassignment(@RequestParam("nodeId") Long nodeId);

    /**
     * 获取兄弟整个家族节点
     *
     * @param brotherFamilyFlowReqDTO brotherFlowReqDTO
     * @return List
     */
    @PostMapping("/remote/application/process/node/brother-family")
    List<NodeRespInfoDTO> getBrotherFlowIds(@Validated @RequestBody BrotherFamilyFlowReqDTO brotherFamilyFlowReqDTO);

    /**
     * 获取所有子级节点
     *
     * @param nodeId nodeId
     * @return List
     */
    @PostMapping("/remote/application/process/node/children")
    List<NodeRespInfoDTO> getAllChildrenNodes(@RequestParam("nodeId") Long nodeId);

    /**
     * 获取动态处理人对应权限控件列表
     *
     * @param dynamicHandlerControlListReqDTO dynamicHandlerControlListReqDTO
     * @return List
     */
    @PostMapping("/remote/application/process/node/dynamic-handler-controls")
    List<ControlBaseInfoDTO> getDynamicHandlerControls(@Validated @RequestBody DynamicHandlerControlListReqDTO dynamicHandlerControlListReqDTO);

    /**
     * 节点信息
     *
     * @param nodeId nodeId
     * @return NodeRespInfoDTO
     */
    @PostMapping("/remote/application/process/node/info")
    NodeRespInfoDTO getNodeInfo(@RequestParam("nodeId") Long nodeId);

    /**
     * 节点应用key
     *
     * @param nodeId nodeId
     * @return NodeRespInfoDTO
     */
    @PostMapping("/remote/application/process/node/applicationKey")
    String getApplicationKeyByNodeId(@RequestParam("nodeId") Long nodeId);

    /**
     * 获取节点处理人
     *
     * @param orderNodeReqDTO orderNodeReqDTO
     * @return List
     */
    @PostMapping("/remote/application/process/node/handlers")
    List<UserEnterpriseDTO> getNodeHandlers(@Validated @RequestBody OrderNodeReqDTO orderNodeReqDTO);
}
